package com.awn.weidian.demo.mapper;

import com.awn.weidian.demo.pojo.User;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;
@Mapper
public interface IUser {

    @Select("select uid,username,nikename,password,realname,age,case when sex = 0 then '男' else '女' end sex,phonenumber,idnumber,autograph,balance,case openseller when '0'  then '非卖家' when '1' then '待审核'  else '卖家' end openseller ,registertime,consumption,defadd,case when state = 0 then '正常使用' else '账户注销' end state from user")
    public List<User> showList();

    @Insert("insert into user(username,nikename,password,realname,age,sex,phonenumber,idnumber,autograph,balance,openseller,registertime,consumption,defadd) values(#{username},#{nikename},#{password},#{realname},#{age},#{sex},#{phonenumber},#{idnumber},#{autograph},#{balance},#{openseller},#{registertime},#{consumption},#{defadd})")
    public int addUser(User user);

//    @Select("select * from tuser where username=#{aa}")
//    public Tuser findOne(String aa);

    @Update("update user set username=#{username},nikename=#{nikename},password=#{password},realname=#{realname},age=#{age},sex=#{sex},phonenumber=#{phonenumber},idnumber=#{idnumber},autograph=#{autograph},balance=#{balance},openseller=#{openseller},registertime=#{registertime},consumption=#{consumption},defadd=#{defadd},state=#{state} where uid = #{uid}")
    public int update(User user);

//    @Delete("delete from user where uid = #{aa}")
//    public int deleteUser(String aa);
}
